package com.zhangliuliu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhangliuliu.bean.LogBean;
import com.zhangliuliu.dao.IUserDao;
import com.zhangliuliu.dao.LogDao;
import com.zhangliuliu.service.LogService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.time.LocalDate;

@Service
@Transactional
public class LogServiceImpl extends ServiceImpl<LogDao,LogBean> implements LogService {
    @Resource
    private IUserDao iUserDao;

    @Override
    public void addLog(LogBean logBean) {
//       iUserDao.login(String name,String pwd);
        save(logBean);
    }

    @Override
    public IPage<LogBean> selectByTime(int pageNo, int pageSize, LocalDate start, LocalDate end) {
     Page<LogBean> Page = new Page<>(pageNo, pageSize);
    QueryWrapper wrapper = new QueryWrapper();
        if (start!=null){
             wrapper.gt("log_date",start);
         }
         if (end!=null){
             wrapper.lt("log_date",end);
         }

        return  this.page(Page,wrapper);
    }


}
